package cn.com.ddapp.ddm.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import cn.com.ddapp.ddm.R;
import cn.com.ddapp.ddm.bean.ShiQuBean;

/**
 * Created by Administrator on 2016/9/1 0001.
 */
public class MoreCityAdapter extends BaseAdapter {
    private Context context;
    private List<ShiQuBean.AddrGroupBean> addrGroup;

    public MoreCityAdapter(Context context, List<ShiQuBean.AddrGroupBean> addrGroup) {
        this.context = context;
        this.addrGroup = addrGroup;
    }

    @Override
    public int getCount() {
        return addrGroup.size();
    }

    @Override
    public Object getItem(int position) {
        return addrGroup.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null) {
            view = LayoutInflater.from(context).inflate(R.layout.item_more_city, viewGroup, false);
            holder=new ViewHolder(view);
            view.setTag(holder);
        }else {
          holder= (ViewHolder) view.getTag();
        }
        holder.moreText.setText(addrGroup.get(position).getName());
        return view;
    }
    class ViewHolder {
        @BindView(R.id.moreText)
        TextView moreText;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
